﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GISCore.Geometry.IO;

namespace GISCore.Geometry
{
    // This class represents a map layer which contains a set of polygons.
    [Serializable]
    public class Layer
    {
        public int LayerID { get; set; }
        private List<Polygon> _polygons;
        private List<Point> _boundingBox;
        private double _averageEdgeLength;

        public Layer() 
        {
            _polygons = new List<Polygon>();
        }

        public Layer(int layerId, List<Polygon> polys)
        {
            LayerID = layerId;
            _polygons = polys;
        }

        public Layer(int layerID, List<Polygon> polys, Point lowerBB, Point upperBB, double avgLineLength)
        {
            LayerID = layerID;
            _polygons = polys;
            _averageEdgeLength = avgLineLength;
            SetBoundingBox(lowerBB, upperBB);
        }

        public IEnumerable<Polygon> GetPolygons()
        {
            return _polygons;
        }

        public List<Point> GetBoundingBox()
        {
            return _boundingBox;
        }

        public void SetBoundingBox(Point lower, Point upper)
        {
            _boundingBox = new List<Point>() { lower, upper };
        }

        public void AddPolygons(IEnumerable<Polygon> polys)
        {
            _polygons.AddRange(polys);
        }

        public void AddPolygon(Polygon p)
        {
            _polygons.Add(p);
        }

        public double GetAvgLineLength()
        {
            return _averageEdgeLength;
        }

    }
}
